import FormData from 'form-data'
import fetch from 'node-fetch'
export default function sendData(options) {
  const form = new FormData();
  if (options.data) {
    for (let key in options.data) {
      form.append(key, options.data[key])
    }
  }
  return fetch(options.url, {
    method: 'POST',
    body: form,
    headers: {
      // 确保设置正确的Content-Type，否则后端可能无法正确解析数据
      ...form.getHeaders(),
      ...(options.headers || {})
    }
  })
}
